package cn.edu.scnu.utils;

import cn.edu.scnu.pojo.User;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 用户登录有关工具类
 */
public class LoginUtils {
    /**
     * 获取当前登录的用户信息
     *
     * @return 用户实体类
     */
    static public User getUserInfo() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        User user = (User) authentication.getPrincipal();
        return user;
    }
}
